﻿using LY.DataAccess.Repository;
using LY.Entity;
using LY.Entity.Entities;
using LY.Entity.PageSearch;
using LY.Entity.SearchEntity;
using LY.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LY.Business.ServiceImpl
{
    public class InformationService:IInformationService    {
        InformationRepository _information;
        public InformationService() 
        {
            _information = new InformationRepository();
        }
        /// <summary>
        /// 查询显示Information列表
        /// </summary>
        /// <param name="search"></param>
        /// <param name="view"></param>
        /// <returns></returns>
        public PagedList<U_Information_EX> QueryInformationList(InformationSearch search, int? touser, PageView view) 
        {
            return _information.QueryInformationList(search,touser, view);
        }
        /// <summary>
        /// 添加一条Information记录
        /// </summary>
        /// <param name="information"></param>
        /// <returns></returns>
        public int AddInformation(U_Information information) 
        {
            return (int)_information.Insert(information);
        }
        /// <summary>
        /// 根据ToUser查询Information列表
        /// </summary>
        /// <param name="touser"></param>
        /// <returns></returns>
        public List<U_Information_EX> GetInformation(int? fromuser) 
        {
            return _information.GetInformation(fromuser);
        }
         //根据Id查询未读消息的记录数
        public int GetInformationCount(int? touser) 
        {
            return _information.GetInformationCount(touser);
        }
        //根据发送者编号检索Informaion列表
        public List<U_Information> GetInformationByFromUser(int? formuser)  
        {
            return _information.GetInformationByFromUser(formuser);
        }
        /// <summary>
        /// 更新消息状态
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int UpdateInformation(int? id)
        {
            return _information.Modify(id);
        }
        /// <summary>
        /// 根据iniformation Id ,获得一个实体对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public U_Information_EX GetById(int? id) 
        {
            return _information.GetInformationById(id);
        
        }
        /// <summary>
        /// 根据id删除消息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Del(int? id) 
        {
            return _information.Del(id);
        
        
        }
    }
}
